#!/usr/bin/perl

use POSIX;
use DBI;

my $dsn = 'DBI:mysql:database=acesso;host=localhost';

my $dbh = DBI->connect($dsn, 'root', '');

while (<STDIN>) {
	chomp;
	if ( $_ = /(\w+\s+\d+\s\d+:\d+:\d+)\s(\w+-?\w+)\S+\w+-?\w+\s+User:(\w+)\s+Skin:(\w+)\s+Statu:(\w+)\s+Action:(\w+)/) {
		$time = $1;
		$servidor = $2;
		$user = $3;
		$skin = $4;
		$status = $5;
		$action = $6;
	}

#	print "$time $servidor $user $skin $status $action\n";

	my $rows = $dbh->do('insert into autenticacao (data, servidor, user, skin, status, action) values (?, ?, ?, ?, ?, ?)', undef, $time, $servidor, $user, $skin, $status, $action);
	
}

$dbh->disconnect;
